#if !defined(MQTT_ZOBJECTPOOL_INCLUDE_H)
#define MQTT_ZOBJECTPOOL_INCLUDE_H
#pragma once
#include "DrvFrame.h"
#include "ZThreadLock.h"


struct TZData 
{
	TSYM_TIME tTime;
	int nQuality;
	int nVT;
	union
	{
		int nValue;
		INT64 nValue64;
		double dbValue;
	};
	std::string csValue;
	void* pMyTag;
	TZData()
	{
		nQuality = 0;
		nVT = 0;
		nValue64 = 0;
		pMyTag = NULL;
	}
};
typedef std::list<TZData*>CZDataList;


class CZObjectPool
{
public:
	CZObjectPool(int nKind,int nMaxSize);
	virtual ~CZObjectPool();
public:
	void Clear();
	int GetCount();
	bool IsFull();
	void Fifo(int nCount);
	void AddObject(void* pValue,bool bLock);
	void DeleteObject(int nIndex);
	void* GetObject(int nIndex,bool bClear);
	void GetObjectPool(CZObjectPool* pPool,bool bLock);

public:
	volatile bool m_bHasNewValues;
	void** m_pPtrBuffer;

private:
	int m_nKind;
	int	m_nMaxSize;
	int m_nNextPos;
	CFSThreadLock	m_oLock;

};
#endif //MQTT_ZOBJECTPOOL_INCLUDE_H
